﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSnsPart.h
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFSnsPart
//
// -------------------------------------------------------------------------

#pragma once

#include <NFLogicCommon/NFLogicShmTypeDefines.h>
#include "NFPart.h"
#include "proto_role.nanopb.h"

class NFSnsPart : public NF_OBJECT_TEMPLATE_MACRO(NFSnsPart, EOT_LOGIC_PART_MIN_ID + PART_SNS, NFPart)
public:
    NFSnsPart();

    ~NFSnsPart() override;

    int CreateInit();
    int ResumeInit();

public:
    //******************part调用接口******************
    /**
     * @brief 所有部件初始化完成
     * @return
     */
    int OnInit() override { return 0; }

public:
    /**
     * @brief 从数据库中加载数据
     * @param data
     * @return
     */
    int LoadFromDB(const proto_ff::tbRoleDetail* pDBData) override;

    /**
     * @brief 从配置中初始化数据
     * @return
     */
    int InitConfig(proto_ff::tbRoleDetail* pDbData, const RoleOne& stRoleOne) override;

    /**
     * @brief 存储DB部件入口
     * @param proto
     * @return
     */
    int SaveDB(proto_ff::tbRoleDetail* pDBData) override;

    int SaveRoleSimpleInfo(proto_ff::Proto_RoleSimpleInfo* pDbData) override;

    /**
     * @brief 登陆入口
     * @return
     */
    int OnLogin() override { return 0; }

    /**
     * @brief 登出入口
     * @return
     */
    int OnLogout() override { return 0; }

    /**
     * @brief 掉线入口
     * @return
     */
    int OnDisconnect() override { return 0; }

    /**
     * @brief 重连入口
     * @return
     */
    int OnReconnect() override { return 0; }

    ////////////////////////////////// 每日零点 每周一零点 刷新接口 ///////////////////////////////////
    /**
     * @brief 每日零点 刷新接口
     * @return
     */
    int DayTick() override { return 0; }

    /**
     * @brief 每日零点 刷新接口
     * @return
     */
    int WeekTick() override { return 0; }

    /**
     * @brief 每月刷新接口
     * @return
     */
    int MonthTick() override { return 0; };

public:
    /**
     * @brief update
     */
    int LogicTick() override { return 0; }

public:
    int MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp) override;
    int MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo) override;

public:
    RoleSnsData* GetData() { return &m_stData; }
    const RoleSnsData* GetData() const { return &m_stData; }

    int GetGuildQuestionIndex() const { return m_stData.guild_role.guild_question.question_index; }
    void SetGuildQuestionIndex(int index);

    int GetGuildCreateTime() const { return m_stData.guild_role.guild_base_info.guild_create_time; }
    int GetGuildMemCount() const { return m_stData.guild_role.guild_base_info.guild_mem_cnt; }
    int64_t GetGuildTotalTax() const { return m_stData.guild_role.guild_mem_info.total_tax; }
    int GetGuildSequenceID() const { return m_stData.guild_role.guild_base_info.sequence_id; }
    int GetGuildPresidentID() const { return m_stData.guild_role.guild_base_info.president_id; }
    enGuildStatus GetGuildStatus() const { return m_stData.guild_role.guild_base_info.status; }
    uint64_t GetGuildID() const { return m_stData.guild_role.guild_base_info.guild_id; }
    std::string GetGuildName() const { return m_stData.guild_role.guild_base_info.guild_name.ToString(); }
    bool IsGuildPresident() const { return m_stData.guild_role.guild_mem_info.guild_title == EN_MEM_TITLE_PRESIDENT; }
    enGuildMemTitle GetGuildTitle() const { return m_stData.guild_role.guild_mem_info.guild_title; }
    int GetJoinTime() const { return m_stData.guild_role.guild_mem_info.join_guild_time; }
    int GetMemDissCreatingTime() const { return m_stData.guild_role.guild_mem_info.diss_creating_guild_time; }
    int GetGuildWeekContribute() const { return m_stData.guild_role.guild_contri.week_contri; }
    void AddGuildWeekContribute(int num);
    int GetGuildWeekBonus() const { return m_stData.guild_role.guild_bonus_info.week_bonus; }
    void AddGuildWeekBonus(int num);
private:
    RoleSnsData m_stData;
};
